package com.sunseaypw.web.serverlet;

import java.io.PrintWriter;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns="/hello/worker")
public class HelloWorkerServerlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
            throws ServletException, java.io.IOException {   
        var a1=req.getSession().getAttribute("attr111");
        if(a1!=null)
           System.out.println(a1);
        var a2=req.getSession().getAttribute("attr222");     
        if(a2!=null)
           System.out.println(a2);

        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");       
        PrintWriter pw = resp.getWriter();
        var filterTxt=req.getAttribute("filter")==null?"":"filter : "+req.getAttribute("filter");
        pw.write("<h1>俺就是个干活的啊！!" + filterTxt +"</h1>");
        pw.flush();
    }
}